package com.homework.ch08;

public class Teacher implements Comparable<Teacher>{
    private int age;
    private String name;
    private String id;

    public Teacher() {
    }

    public Teacher(int age, String name, String id) {
        this.age = age;
        this.name = name;
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Teacher{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", id='" + id + '\'' +
                '}';
    }

    @Override
    public int compareTo(Teacher o) {
        if(this.name.compareTo(o.name)==0){
            if(this.age-o.age==0){
                return this.id.compareTo(o.id);
            }else{
                return this.age-o.age;
            }
        }else{
            return this.name.compareTo(o.name);
        }
    }
}
